%GLOBAL CWD; %LET CWD = %SUBSTR(%SYSGET(SAS_EXECFILEPATH), 1, %EVAL(%LENGTH(%SYSGET(SAS_EXECFILEPATH)) - %LENGTH(%SYSGET(SAS_EXECFILENAME)) - 1));
%INCLUDE "&CWD\TOOLS.SAS";

/* SET ELI & CLUSTER */
%LET ELI = FK011;
%LET CLUSTER = 01A;

/* IDENTIFYING HANDLE */
%LET COM = &ELI._&CLUSTER.;

/* ITEM-SPECIFIC RIGHT HAND SIDE VARIABLES */
%LET RHS = 
    A3 A4 A5 A6 A9 A10 A11 A12 A13 A15  A16 A17 A18
    A99SP C1 C2 D99SP E99SP F1 G1 H1 H2 I1 I2 J99SP K99SP MNAMT MNAMTSQ 
    ;

%LET STYR = 0201;
%LET FIRSTPER = 20&STYR.;
%LET LASTPER = 200709;
%LET STDUM = D&STYR.;
%LET RHYRS = D0202 -- D0709;

%LET NSPER = %COUNTMONTHS(&FIRSTPER, &LASTPER);
%LET NVEC = %EVAL(&NSPER + %COUNTWORDS(&RHS));

/* DEFINE ITEM-SPECIFIC PRICE EDITS */
%MACRO EDITS;   
    IF .01 > FULLSAMP_EFFPR_WOTX OR FULLSAMP_EFFPR_WOTX > .8 THEN DELETE;   
%MEND;

/* DEFINE ITEM-SPECIFIC DUMMIES */
%MACRO VARS;
    A1=(A="A1"); A2=(A="A2"); A3=(A="A3"); A4=(A="A4"); 
    A5=(A="A5"); A6=(A="A6"); A7=(A="A7"); A8=(A="A8"); 
    A9=(A="A9"); A10=(A="A10"); A11=(A="A11"); A12=(A="A12"); 
    A13=(A="A13"); A14=(A="A14"); A15=(A="A15"); A99SP=(A="A99"); 
    A16=(A99="**********" OR a99="**********" or A99="**********");
    A17=(A99="**********" OR a99="**********");
    A18=(A99="**********" OR a99="**********" or A99="**********" or A99="**********");
    A99SP=(A="A99") AND A16+A17+A18=0;

    ARRAY AARRAY (19) A1-A18 A99SP;
    DO COUNT=1 TO 19;
    IF A="" THEN AARRAY(COUNT)=.;
    END;

    C1=(C="C1"); C2=(C="C2"); C3=(C="C3");
    ARRAY CARRAY (4) C1-C3 C99SP;
    DO COUNT=1 TO 4;
    IF C="" THEN CARRAY(COUNT)=.;
    END;

    D99SP=(D="D99"); 
    E99SP=(E="E99"); 

    F1=(F="F1"); F2=(F="F2");
    ARRAY FARRAY (2) F1-F2;
    DO COUNT=1 TO 2;
    IF F="" THEN FARRAY(COUNT)=.;
    END;

    G1=(G="G1"); G2=(G="G2"); 
    ARRAY GARRAY (2) G1-G2;
    DO COUNT=1 TO 2;
    IF G="" THEN GARRAY(COUNT)=.;
    END;

    H1=(H="H1"); H2=(H="H2");H3=(H="H3"); 
    ARRAY HARRAY (3) H1-H3;
    DO COUNT=1 TO 3;
    IF H="" THEN HARRAY(COUNT)=.;
    END;

    I1=(I="I1"); I2=(I="I2");I3=(I="I3"); 
    ARRAY iARRAY (3) I1-I3;
    DO COUNT=1 TO 3;
    IF I="" THEN IARRAY(COUNT)=.;
    END;

    J99SP=(J="J99"); 
    K99SP=(K="K99");

    *ELIMINATE QUOTES WITH MISSING SPEC VARIABLES;
    *INCLUDE APPROPRIATE LIST OF SPEC VARIABLES HERE AND ELSEWHERE;
    *MODIFY SIZE OF SPECARRAY AS NEEDED TO NUMBER OF YOUR SPEC VARIABLES PLUS 5;
    *;
    ARRAY SPECARRAY (29)
        A3 A4 A5 A6 A9 A10 A11 A16 A17 A18 
        A99SP C1 C2 D99SP E99SP F1 G1 H1 H2 I1 
        I2 J99SP K99SP
        DISCDEP--OTHSTORE;
    DO COUNT=1 TO 29;
        IF SPECARRAY(COUNT)=. THEN DELETE;
    END;
%MEND;

LIBNAME IN "&CWD\DATA";
LIBNAME OUT "&CWD\DATA";

FILENAME OUTLOGS "&CWD\OUTPUT\LOGINDEXES.XLS";
FILENAME OUTCONTS "&CWD\OUTPUT\LOGCONTRIBS.XLS";
FILENAME OUTDISCS "&CWD\OUTPUT\DISCOUNTS.XLS";
FILENAME OUTPCTLS "&CWD\OUTPUT\PCTLS.XLS";

%INCLUDE "&CWD\TABLESTOBUILD.SAS";

